import * as actionTypes from "./constance";

import {
  getArtistInformation,
  getArtists,
  getArtistAlbum,
  getArtistMV,
  getArtistDesc,
  getArtistSimi,
} from "@/services/artist";

const artistInformation = (res) => ({
  type: actionTypes.GET_ARTIST_INFORMATION,
  Information: res.data,
});

const getArtist = (res) => ({
  type: actionTypes.GET_ARTISTS,
  artists: res,
});

const getArtistAlbums = (res) => ({
  type: actionTypes.GET_ARTIST_ALBUM,
  artistAlbum: res,
});
const getArtistMv = (res) => ({
  type: actionTypes.GET_ARTIST_MV,
  artistMV: res,
});
const getArtistDescInfo = (res) => ({
  type: actionTypes.GET_ARTIST_DESC,
  artistDesc: res,
});
const getArtistSimiInfo = (res) => ({
  type: actionTypes.GET_ARTIST_SIMI,
  artistSimiInfo: res,
});

export const artistInformationAction = (id) => {
  return (dispatch) => {
    getArtistInformation(id).then((res) => {
      dispatch(artistInformation(res));
    });
  };
};

export const getArtistsAction = (id) => {
  return (dispatch) => {
    getArtists(id).then((res) => {
      dispatch(getArtist(res));
    });
  };
};

export const getArtistAlbumAction = (id, limit, offset) => {
  return (dispatch) => {
    getArtistAlbum(id, limit, offset).then((res) => {
      dispatch(getArtistAlbums(res));
    });
  };
};

export const getArtistMVAction = (id, limit, offset) => {
  return (dispatch) => {
    getArtistMV(id, limit, offset).then((res) => {
      dispatch(getArtistMv(res));
    });
  };
};
export const getArtistDescAction = (id) => {
  return (dispatch) => {
    getArtistDesc(id).then((res) => {
      dispatch(getArtistDescInfo(res));
    });
  };
};
export const getArtistSimiAction = (id) => {
  return (dispatch) => {
    getArtistSimi(id).then((res) => {
      dispatch(getArtistSimiInfo(res));
    });
  };
};
